import { Tag } from 'ant-design-vue';
import type { TableColumn } from '@/components/core/dynamic-table';

export type TableListItem = API.OperActionListResultItem;
export type TableColumnItem = TableColumn<TableListItem>;

export const baseColumns: TableColumnItem[] = [
  {
    title: '操作按钮编号',
    align: 'center',
    dataIndex: 'ACTION_NO',
    hideInTable: true,
    hideInSearch: true,
  },
  {
    title: '操作按钮名称',
    dataIndex: 'ACTION_NAME',
    hideInSearch: false,
    align: 'center',
  },
  {
    title: '起草节点是否启用',
    dataIndex: 'ACTION_START_ENABLE',
    hideInSearch: true,
    align: 'center',
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: [
          {
            label: '是',
            value: 1,
          },
          {
            label: '否',
            value: 0,
          },
        ],
      },
    },
    customRender: ({ record }) => {
      const isEnable = record.ACTION_START_ENABLE === 1;
      return <Tag color={isEnable ? 'success' : 'red'}>{isEnable ? '是' : '否'}</Tag>;
    },
  },
  {
    title: '审批节点是否启用',
    dataIndex: 'ACTION_RUN_ENABLE',
    hideInSearch: true,
    align: 'center',
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: [
          {
            label: '是',
            value: 1,
          },
          {
            label: '否',
            value: 0,
          },
        ],
      },
    },
    customRender: ({ record }) => {
      const isEnable = record.ACTION_RUN_ENABLE === 1;
      return <Tag color={isEnable ? 'success' : 'red'}>{isEnable ? '是' : '否'}</Tag>;
    },
  },
  {
    title: '历史节点是否启用',
    dataIndex: 'ACTION_HIS_ENABLE',
    hideInSearch: true,
    align: 'center',
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: [
          {
            label: '是',
            value: 1,
          },
          {
            label: '否',
            value: 0,
          },
        ],
      },
    },
    customRender: ({ record }) => {
      const isEnable = record.ACTION_HIS_ENABLE === 1;
      return <Tag color={isEnable ? 'success' : 'red'}>{isEnable ? '是' : '否'}</Tag>;
    },
  },
];
